package com.example.supplychainbackend.mapper;

import com.example.supplychainbackend.controller.dto.quality.*;
import com.example.supplychainbackend.entity.quality.*;
import org.mapstruct.*;

import java.util.List;

@Mapper(componentModel = "spring",
        builder = @Builder(disableBuilder = true),
        nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface QualityMapper {

    List<InspectionBatchDto> toInspectionBatchDtoList(List<InspectionBatchEntity> all);
    InspectionBatchDto toInspectionBatchDto(InspectionBatchEntity inspectionBatchEntity);
    InspectionBatchEntity toInspectionBatchEntity(InspectionBatchDto form);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "inspectionBatchNumber", ignore = true)
    void updateInspectionBatchEntity(InspectionBatchDto form, @MappingTarget InspectionBatchEntity inspectionBatchEntity);

    List<UnqualifiedDto> toUnqualifiedDtoList(List<UnqualifiedEntity> all);
    UnqualifiedEntity toUnqualifiedEntity(UnqualifiedDto form);
    UnqualifiedDto toUnqualifiedDto(UnqualifiedEntity save);
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "nonconformingProductNumber", ignore = true)
    void updateUnqualifiedEntity(UnqualifiedDto form, @MappingTarget UnqualifiedEntity entity);

    InspectionRequestDto toInspectionRequestDto(InspectionRequestEntity entity);
    InspectionRequestEntity toInspectionRequestEntity(InspectionRequestDto dto);
    InspectionRequestListDto toInspectionRequestListDto(InspectionRequestEntity entity);
    List<InspectionRequestListDto> toInspectionRequestListDto(List<InspectionRequestEntity> entities);
    void updateFromDto(@MappingTarget InspectionRequestEntity entity, InspectionRequestDto dto);

    @Mapping(target = "inspectionMethod", ignore = true)
    void updateFromItem(@MappingTarget InspectionRequestEntity entity, InspectionItemEntity itemEntity);

    InspectionOrderDto toInspectionOrderDto(InspectionOrderEntity entity);
    InspectionOrderEntity toInspectionOrderEntity(InspectionOrderDto dto);
    List<InspectionOrderListDto> toInspectionOrderListDto(List<InspectionOrderEntity> entities);
    void updateFromDto(@MappingTarget InspectionOrderEntity entity, InspectionOrderDto dto);

    void updateOrderFromRequest(@MappingTarget InspectionOrderEntity orderEntity,InspectionRequestEntity requestEntity);
}
